// #ifdef APP || H5
import { getAppConfig } from '@/common/config/config.js'
const { BASE_URL } = getAppConfig();
// #endif
import {mapGetters,mapActions,mapState} from "vuex"

export default{
  data(){
    return{
      user:{
        username:"admin",
        password:"123123"
      },
	   switchVal: false
    }
  },
  computed: {
      ...mapState('theme', ['currentTheme']),
      ...mapGetters('theme', ['isDarkTheme', 'themeConfig']),
      platform() {
        return uni.getSystemInfoSync().platform
      }
    },
  methods:{
	...mapActions('theme', ['initTheme', 'setTheme']),
    login(){
      this.$store.commit("login/GET_USER",this.user);
	  
    },
	// 中英文切换
	langChange(command) {
	    this.$i18n.locale = command
	    localStorage.setItem("lang", command)
	    if(command == 'en') {
	        this.language = 'English'
	    } else if (command == 'zh') {
	        this.language = '中文'
	    }
	},

	 switchChange(){
	  this.switchVal=!this.switchVal;
	  this.SwitchThemes(this.switchVal);
	},
	
    
    async toggleTheme() {
      const newTheme = this.isDarkTheme ? 'light' : 'dark'
      await this.setTheme(newTheme)
      this.updatePageStyle()
    },

    updatePageStyle() {
      // 处理NVUE特殊逻辑
      /* #ifdef APP-NVUE */
      const style = this.themeConfig
      this.$refs.container.updateStyle({
        backgroundColor: style.bg
      })
      /* #endif */
    },
	
  },
  mounted() {
    // #ifdef APP || H5
    console.log(BASE_URL);
    // #endif
	this.initTheme()
  },
}
